import {Controller, Get, Param, Post, Body} from '@nestjs/common';
import {CreateDto} from './dto/create-mongoose.dto'
import {MongooseService} from "./mongoose.service";
import {Mongoose} from "./interfaces/mongoose.interface";

@Controller('mongoose')
export class MongooseController {
    constructor(private readonly mongooseService: MongooseService) {
    }

    // 创建
    @Post()
    async create(@Body() createMongooseDto: CreateDto) {
        return this.mongooseService.create(createMongooseDto)
    }

    // 查询所有
    @Get()
    async findAll(): Promise<Mongoose[]> {
        return this.mongooseService.findAll()
    }

    // 根据id查询
    @Get(':id')
    async findById(@Param('id') id): Promise<Mongoose> {
        return this.mongooseService.findById(id)
    }
}
